<?php

namespace App\SearchRules;

use ScoutElastic\SearchRule;

class UserSearchRule extends SearchRule
{
    /**
     * @inheritdoc
     */
    public function buildHighlightPayload()
    {
        return [
            "pre_tags" => ['<font color="red">'],
            "post_tags" => ['</font>'],
            'fields' => [
                "name" => ['type' => 'plain'],
                "email" => ['type' => 'plain'],
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function buildQueryPayload()
    {
        $query = "*{$this->builder->query}*";
        return [
            "should" => [
                ["wildcard" => ["name" => $query]],
                ["wildcard" => ["email" => $query]],
            ],
        ];
    }
}